package #(package.ServiceImpl);
#set(lowerMapperName = StrUtil.lowerFirst(table.mapperName))
#set(RqsDto = entity + 'RqsDto')
#set(rqsDto = StrUtil.lowerFirst(RqsDto))
import cn.hutool.core.bean.BeanUtil;
import #(package.Controller).validator.dto.#(RqsDto);
import com.interheart.framecore.dto.PageDto;
import com.interheart.framecore.dto.PageRqsDto;
import #(package.Entity).#(entity);
import #(package.Mapper).#(table.mapperName);
import #(superServiceImplClassPackage);
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * #(table.comment??) 服务实现类
 * </p>
 *
 * @author #(author)
 * @date  #(date)
 */
@Service
#if(kotlin)
open class #(table.serviceImplName) : #(superServiceImplClass)<#(table.mapperName), #(entity)>(), #(table.serviceName) {

}
#else
public class #(table.serviceImplName) extends #(superServiceImplClass)<#(table.mapperName), #(entity)> {

    @Autowired
    #(table.mapperName) #(lowerMapperName);

    /**
     * 功能描述 列表
     * @author SHIKAI
     * @date 2019/1/3
     * @param
     * @return
     */
    #if(restControllerStyle)
    public PageDto<#(entity)> list(#(RqsDto) #(rqsDto)){
        QueryWrapper<#(entity)> queryWrapper = new QueryWrapper<>();
        #(entity) #(table.entityPath) = new #(entity)();
        BeanUtil.copyProperties(#(rqsDto), #(table.entityPath));
        queryWrapper.setEntity(#(table.entityPath));
        return (PageDto<#(entity)>) #(lowerMapperName).selectPage(#(rqsDto).getPageDto(), queryWrapper);
    }
    #else
    public PageDto<#(entity)> list(PageRqsDto pageRqsDto, #(entity) #(table.entityPath)){
        QueryWrapper<#(entity)> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(#(table.entityPath));
        return (PageDto<#(entity)>) #(lowerMapperName).selectPage(pageRqsDto.getPageDto(), queryWrapper);
    }
    #end
}
#end
